// stdafx.cpp : source file that includes just the standard includes
// DA BG.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information

#include "stdafx.h"

String^ GlobalTime::GetTime()
{
	String ^result = gcnew String( Convert::ToString(DateTime::Now) );
	String^ delimStr = " ";
	array<Char>^ delimiter = delimStr->ToCharArray( );
	array<String^>^ words;
	String^ line = Convert::ToString(result);
	words = line->Split( delimiter );

	return "<" + words[1] + "> ";
}

String^ GlobalVars::ConvertServerToTime(double srvTime)
{
	long timeAsInteger = srvTime;
	double tmpTime = Convert::ToDouble(timeAsInteger);

	DateTime ^baseDate = gcnew DateTime(1970, 1, 1);
	DateTime ^result = gcnew DateTime;
	result = baseDate->Add(TimeSpan::FromSeconds(tmpTime));

	String^ delimStr = " ";
	array<Char>^ delimiter = delimStr->ToCharArray( );
	array<String^>^ words;
	String^ line = Convert::ToString(result);
	words = line->Split( delimiter );
	delimStr = ":";
	delimiter = delimStr->ToCharArray( );
	line = words[1];
	words = line->Split( delimiter );

	return words[0] + ":" + words[1] + ":" + words[2];
}

String^ GlobalVars::ConvertServerToDate(double srvTime)
{
	long timeAsInteger = srvTime;
	double tmpTime = Convert::ToDouble(timeAsInteger);

	DateTime ^baseDate = gcnew DateTime(1970, 1, 1);
	DateTime ^result = gcnew DateTime;
	result = baseDate->Add(TimeSpan::FromSeconds(tmpTime));

	String^ delimStr = " ";
	array<Char>^ delimiter = delimStr->ToCharArray( );
	array<String^>^ words;
	String^ line = Convert::ToString(result);
	words = line->Split( delimiter );

	return words[0];
}

String^ GlobalVars::ConvertHistoryToTime(String^ strTime)
{
	String^ delimStr = " ";
	array<Char>^ delimiter = delimStr->ToCharArray( );
	array<String^>^ words;
	String^ line = strTime;
	words = line->Split( delimiter );

	return words[2];
}

String^ GlobalVars::ConvertHistoryToDate(String^ strDate)
{
	String^ delimStr = " ";
	array<Char>^ delimiter = delimStr->ToCharArray( );
	array<String^>^ words;
	String^ line = strDate;
	words = line->Split( delimiter );

	return words[0]->Substring(6,2) + "/" + words[0]->Substring(4,2) + "/" + words[0]->Substring(0,4);
}
